Add 'nukedata' filter to remove waypoints, tracks, and routes.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 4 Nov 2005 23:11:41 +0000 (23:11 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 4 Nov 2005 23:11:41 +0000 (23:11 +0000)
gpsbabel/filter_vecs.c
gpsbabel/nukedata.c [new file with mode: 0644]
gpsbabel/route.c

index 3a5568f85981575d0a3ea235f1e8caba8191c320..0249b3a241971551de29e2786f82b49dae09edf5 100644 (file)
@@ -39,6 +39,7 @@ extern filter_vecs_t sort_vecs;
 extern filter_vecs_t stackfilt_vecs;
 extern filter_vecs_t trackfilter_vecs;
 extern filter_vecs_t discard_vecs;
+extern filter_vecs_t nuke_vecs;
 
 static
 fl_vecs_t filter_vec_list[] = {
@@ -97,6 +98,11 @@ fl_vecs_t filter_vec_list[] = {
                "discard",
                "Remove unreliable points with high hdop or vdop"
        },
+       {
+               &nuke_vecs,
+               "nuketypes",
+               "Remove all waypoints, tracks, or routes"
+       },
         {
                NULL,
                NULL,
diff --git a/gpsbabel/nukedata.c b/gpsbabel/nukedata.c
new file mode 100644 (file)
index 0000000..3b2f963
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+
+    nukedata: remove all (waypoint|tracks|routes) from the stream.
+    
+    Copyright (C) 2005 Robert Lipe   robertlipe@usa.net
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+#include "defs.h"
+#include "filterdefs.h"
+
+#define MYNAME "nukedata"
+
+static char *nukewpts, *nuketrks, *nukertes;
+
+static
+arglist_t nuke_args[] = {
+       {"waypoints", &nukewpts, "Remove all waypoints from data stream.", 
+          "0", ARGTYPE_BOOL} , 
+       {"tracks", &nuketrks, "Remove all tracks from data stream.", 
+          "0", ARGTYPE_BOOL} , 
+       {"routes", &nukertes, "Remove all routes from data stream.", 
+          "0", ARGTYPE_BOOL} , 
+       {0, 0, 0, 0, 0}
+};
+
+static void 
+nuke_process(void)
+{
+       if (nukewpts) {
+               waypt_flush_all();
+       }
+       if (nuketrks) {
+               route_flush_all_tracks();
+       }
+       if (nukertes) {
+               route_flush_all_routes();
+       }
+}
+
+filter_vecs_t nuke_vecs = {
+       NULL,
+       nuke_process,
+       NULL,
+       NULL,
+       nuke_args
+};
+
index 121c1c1e0b6b2b48877dda13be580a7714718883..52c76b4125f9ec98cf275cc587853a6227bbd4e8 100644 (file)
@@ -228,8 +228,8 @@ track_disp_all(route_hdr rh, route_trl rt, waypt_cb wc)
        common_disp_all(&my_track_head, rh, rt, wc);
 }
 
-void
-route_flush(queue *head)
+static void
+route_flush_q(queue *head)
 {
        queue *elem, *tmp;
        queue *q;
@@ -241,15 +241,27 @@ route_flush(queue *head)
 }
 
 void
-route_flush_all()
+route_flush_all_routes(void)
 {
-       route_flush(&my_route_head);
-       route_flush(&my_track_head);
+       route_flush_q(&my_route_head);
        rte_head_ct = 0;
-       trk_head_ct = 0;
        rte_waypts = 0;
 }
 
+void
+route_flush_all_tracks(void)
+{
+       route_flush_q(&my_track_head);
+       trk_head_ct = 0;
+}
+
+void
+route_flush_all()
+{
+       route_flush_all_tracks();
+       route_flush_all_routes();
+}
+
 void
 route_backup(unsigned int *count, queue **head_bak)
 {
@@ -332,7 +344,7 @@ route_restore(unsigned int count, queue *head_bak)
 {
        if (head_bak == NULL) return;
        
-       route_flush(&my_route_head);
+       route_flush_q(&my_route_head);
        QUEUE_INIT(&my_route_head);
        QUEUE_MOVE(&my_route_head, head_bak);
        xfree(head_bak);
@@ -388,7 +400,7 @@ track_restore(unsigned int count, queue *head_bak)
 {
        if (head_bak == NULL) return;
        
-       route_flush(&my_track_head);
+       route_flush_q(&my_track_head);
        QUEUE_INIT(&my_track_head);
        QUEUE_MOVE(&my_track_head, head_bak);
        xfree(head_bak);